package cn.edu.cug.controller;

import cn.edu.cug.bean.ResultResponse;
import org.json.JSONArray;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by xhhuang on 2017/11/8.
 */

@Controller
@RequestMapping("/menu")
public class MenuController {
  private static final Logger LOG = LoggerFactory.getLogger(MenuController.class);

  @RequestMapping("dataLoadManage")
  public String dataLoadManage(){
    return "dataLoadManage";
  }

  @RequestMapping("dataQuery")
  public String dataQuery(){
    return "dataQuery";
  }

  @RequestMapping("dataSetManage")
  public String dataSetManage(){
    return "dataSetManage";
  }

  @RequestMapping("dataSetExample")
  public String dataSetExample(){
    return "dataSetExample";
  }

  @RequestMapping(value = "getInfoTest", method = RequestMethod.POST)
  @ResponseBody
  public String getInfoTest() {
    System.out.print("Get Here.");
    ResultResponse resultResponse = new ResultResponse();

    String result = "Hello From getInfoTest()";

    return result;
  }

  @RequestMapping(value = "test", method = RequestMethod.POST)
  @ResponseBody
  public Object test(){
    ResultResponse resultResponse = new ResultResponse();

    List<String> fileNameList = new ArrayList<String>();

    fileNameList.add("dubo");
    fileNameList.add("xhhuang");
    fileNameList.add("zhanggen");

    LOG.info("Add fileNameList to ResultResponse");

    return fileNameList;
  }

  @RequestMapping(value = "test2", method = RequestMethod.POST)
  @ResponseBody
  public ResultResponse test2(){
    ResultResponse resultResponse = new ResultResponse();
    List list=new ArrayList();
    Map name1 = new HashMap();
    Map name2=new HashMap();
    name1.put("name", "db");
    name1.put("size", "24");
    list.add(name1);
    name2.put("name","hxh");
    name2.put("size","23");
    list.add(name2);

    resultResponse.setData(list);

    //LOG.info("ResultResponse Info: "+resultResponse.getCode()+""+resultResponse.getData());

    return resultResponse;
  }



}
